<template>
  <footer class="footer">
    <span class="todo-count">剩余<strong>数量值：{{ total }}</strong></span>
    <ul class="filters">
      <li>
        <a :class="{selected: type === 'all'}" href="javascript:" @click="fn('all')">全部</a>
      </li>
      <li>
        <a :class="{selected: type === 'no'}" href="javascript:" @click="fn('no')">未完成</a>
      </li>
      <li>
        <a :class="{selected: type === 'yes'}" href="javascript:" @click="fn('yes')">已完成</a>
      </li>
    </ul>
    <button class="clear-completed" @click="clearFn">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props: ['arr', 'type'],
  computed: {
    total() {
      return this.arr.length
    }
  },
  methods: {
    fn(type) {
      this.$emit('changeType', type)
    },
    clearFn() {
      this.$emit('clearFn')
    }
  },
}
</script>
